// LoadCfg.h: interface for the CLoadCfg class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_LOADCFG_H__AE47A934_65E9_499B_94B3_16706C746CD0__INCLUDED_)
#define AFX_LOADCFG_H__AE47A934_65E9_499B_94B3_16706C746CD0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <map>
using namespace std;

typedef struct  _Cfg_System{
	BOOL bAutoSetDo;
	BOOL bAutoStart;
	BOOL bAutoRestart;
} Cfg_System;

typedef struct  _Cfg_Network{
	char szIp[20];
	USHORT remote_port;
	USHORT local_port;
} Cfg_Network;

typedef struct  _Cfg_Period{
	unsigned short sample;
	unsigned short gi;
} Cfg_Period;

typedef struct  _Cfg_TotalData{
	unsigned short NodeNo;
	unsigned short SbcNo;
} Cfg_TotalData;

typedef struct  _Cfg_ADC1{
	unsigned short DevNum;
	unsigned short gainlist[16];
	unsigned short pos[16];
	unsigned int freq;
} Cfg_ADC1;

typedef struct  _Cfg_ADC2{
	unsigned short DevNum;
	unsigned short gainlist[16];
	unsigned short pos[16];
	unsigned int freq;
} Cfg_ADC2;

typedef struct  _Cfg_DIO{
	unsigned short DevNum;
	unsigned char DO_OFF[3];
	unsigned char DO_ON[3];
	unsigned char DO_INIT[3];
} Cfg_DIO;

typedef struct  _Cfg_CAN{
	unsigned short DevNum;
	unsigned char ID;
	unsigned short maxtimes;
	unsigned int timeout;
	unsigned int scantime;
	bool         b_Only_Recv;
	unsigned short b1_pos[CAN1_channelNum];
	unsigned char b1_id;
	
	unsigned short b2_pos[CAN2_channelNum];
	unsigned char b2_id;

	unsigned short b3_pos[CAN3_channelNum];
	unsigned char b3_id;

	unsigned short b4_pos[CAN4_channelNum];
	unsigned char b4_id;
} Cfg_CAN;

typedef struct _Cfg_GFValue{
	unsigned char pos[GFVALUE_Num];
}Cfg_GFValue;

typedef struct _Cfg_Value{
	unsigned int ratio;
	unsigned int threshold;
	unsigned char DIO_port;
	unsigned char EventId;
	unsigned char EventNo;
}Cfg_Value;

typedef struct _Cfg_Threshold{
	unsigned int threshold;
	unsigned short ValuePos[16];
}Cfg_Threshold;

class CLoadCfg  
{
public:
	CLoadCfg();
	virtual ~CLoadCfg();

//Opreations
public:
	int Init();
public:
	Cfg_System cfg_system;
    Cfg_Network cfg_network;
	Cfg_Period cfg_period;
	Cfg_TotalData cfg_totaldata;
	Cfg_ADC1 cfg_adc1;
	Cfg_ADC2 cfg_adc2;
	Cfg_DIO  cfg_dio;
	Cfg_CAN  cfg_can;
	Cfg_GFValue cfg_gf;
	std::map<int,int> SetThresholdMap;
	std::map<int,int> ChangeDoStateMap;
	std::map<int,Cfg_Value> ValueMap;
	std::map<int,Cfg_Threshold> ThresholdMap;
};

#endif // !defined(AFX_LOADCFG_H__AE47A934_65E9_499B_94B3_16706C746CD0__INCLUDED_)
